import os
import re
import numpy as np
import pandas as pd


def read_in(path):
    files = os.listdir(path)
    holding = {}
    i = 0
    for file in files:
        sub_path = os.path.join(path, file)
        name = re.sub("[\u4e00-\u9fa5\0-9\,\.]", '', file[:-3])
        data_read = pd.read_csv(sub_path, delim_whitespace=True)
        data_read['label'] = name
        holding[i] = data_read
        i += 1
    dataset = pd.concat(list(holding.values()), ignore_index=True)
    label = np.array(dataset['label'])
    data = np.array(dataset.drop(['ID', 'X', 'Y', 'label'], axis=True))

    return data, label
